<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
<!--     <link rel="shortcut icon" href="../../assets/ico/favicon.png"> -->

    <title>SGI</title>

    <!-- Bootstrap core CSS -->
    <link href="css/bootstrap-3.1.1.css" rel="stylesheet" media="screen">

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="../../assets/js/html5shiv.js"></script>
      <script src="../../assets/js/respond.min.js"></script>
    <![endif]-->
  </head>

<body >

	<!-- Static navbar -->
	<div class="navbar navbar-default navbar-static-top">
	  <div class="container">
	    <div class="navbar-header">
	      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
	        <span class="icon-bar"></span>
	        <span class="icon-bar"></span>
	        <span class="icon-bar"></span>
	      </button>
	      <a class="navbar-brand" href="principal.jsp">SGI</a>
	    </div>
	    <div class="navbar-collapse collapse">
	      <ul class="nav navbar-nav">
	        <li><a href="principal.jsp">Inicio</a></li>
	        <li class="dropdown active">
	          <a href="#" class="dropdown-toggle" data-toggle="dropdown">Mantenimientos <b class="caret"></b></a>
	          <ul class="dropdown-menu">
	            <li><a href="#">Ideas</a></li>
	            <li><a href="usuario_buscar.jsp">Usuarios</a></li>	              
	          </ul>
	        </li>
	        <li><a href="#">Reportes</a></li>	          
	        <li><a href="LogoutServlet">Salir</a></li>
	      </ul>
	    </div><!--/.nav-collapse -->
	  </div>
	</div>

	<div class="container"> 
	
		<!-- I. Configurando variables y comportamiento del formulario para INSERTAR o ACTUALIZAR -->
		<% String xTitulo = "";%>
		
		<%if (request.getParameter("hidIdUsuario") != null && request.getParameter("hidOperacion").equals("2")) {%>
			<form name="frmcarga" action="UsuarioRegistrarServlet" method="post">
				<input type="hidden" id="operacion" name="txtOperacion" value="6"/>
				<input type="hidden" id="IdUsuario" name="txtIdUsuario" value="<%=request.getParameter("hidIdUsuario")%>"/>
			</form>
			<script >
		//		alert('consultando');
				document.frmcarga.submit();
			</script>
		<%} %>
	
		<%
		String xOperacion = (String) request.getAttribute("attr_txtOperacion");
		String xIdUsuario = (String) request.getAttribute("attr_txtIdUsuario");
		
		String xNombres = (String) request.getAttribute("nombre");
		String xAP = (String) request.getAttribute("ap");
		String xAM = (String) request.getAttribute("am");
		String xSexo = (String) request.getAttribute("sexo");
		String xTipoDoc = (String) request.getAttribute("tipodoc");
		String xNroDoc = (String) request.getAttribute("nrodoc");
		String xCorreo = (String) request.getAttribute("correo");
		String xCelular = (String) request.getAttribute("celular");
		String xClave = (String) request.getAttribute("clave");
		String xTipoUsuario = (String) request.getAttribute("tipousuario");	
	
		//Configurar operacion
		if (xOperacion == null) {
			xOperacion = request.getParameter("hidOperacion");
		}
		
		
		if (xOperacion.equals("2")) {
			xTitulo = "Modificar Usuario";	
		}
		else {
			xTitulo = "Crear Usuario";
		}
	
		//Configurar id usuario
		if (xIdUsuario == null)  {
			if (request.getParameter("hidIdUsuario") != null) {
				xIdUsuario = request.getParameter("hidIdUsuario");
			} 
			else { 
				xIdUsuario = "0";
			}
		}
		
		if (xNombres == null) xNombres = "";
		if (xAP == null) xAP = "";
		if (xAM == null) xAM = "";
		if (xSexo == null) xSexo = "";
		if (xTipoDoc == null) xTipoDoc = "";
		if (xNroDoc == null) xNroDoc = "";
		if (xCorreo == null) xCorreo = "";
		if (xCelular == null) xCelular = "";
		if (xClave == null) xClave = "";
		if (xTipoUsuario == null) xTipoUsuario = "";
		%>
		
		
		<!-- II. Formulario para INSERTAR o ACTUALIZAR -->
		<p><strong>Mantenimiento de Usuarios &gt; <%=xTitulo%> </strong></p>
		<form id="form1" name="form1" action="UsuarioRegistrarServlet" method="post"  class="form-horizontal" role="form">	
			<table width="300" height="104" border="0" cellpadding="0" cellspacing="0">
			    <tr>
			      <td>Nombre:</td>
			      <td><label>
			        <input id="nombre" type="text" name="txtNombre" value="<%=xNombres%>"  required autofocus/>
			      </label></td>
			    </tr>				
			    <tr>
			      <td>Apellido Paterno:</td>
			      <td><label>
			        <input id="AP" type="text" name="txtAP" value="<%=xAP%>" required />
			      </label></td>
			    </tr>				
			    <tr>
			      <td>Apellido Materno:</td>
			      <td><label>
			        <input id="AM" type="text" name="txtAM" value="<%=xAM%>" required  />
			      </label></td>
			    </tr>				
			    <tr>
			      <td>Sexo:</td>
			      <td><label>
						<input id="sexo" type="radio" name="txtSexo" value="M"  <%if (xSexo.equals("M")) { %>checked <%}%> required />Masculino
						<input id="sexo" type="radio" name="txtSexo"  value="F" <%if (xSexo.equals("F")) { %>checked <%}%>  required />Femenino			        
			      </label></td>
			    </tr>				
			    <tr>
			      <td>Tipo de documento:</td>
			      <td><label>
						<input list="TipoDoc" type="text" name="txtTipoDoc"  value="<%=xTipoDoc%>" required/>
						<datalist id="TipoDoc">
							<option value="DNI"   />
							<option value="Carnet Universitario"  />
						</datalist>
			      </label></td>
			    </tr>	
			    <tr>
			      <td># de documento:</td>
			      <td><label>
						<input id="NroDoc" type="text" name="txtNroDoc" value="<%=xNroDoc%>" required/>
			      </label></td>
			    </tr>	
			    <tr>
			      <td>Correo:</td>
			      <td><label>
						<input id="Correo" type="email" name="txtCorreo" value="<%=xCorreo%>"  required placeholder="Ingrese el correo aqu&iacute;" />
			      </label></td>
			    </tr>

			    <tr>
			      <td>Celular:</td>
			      <td><label>
						<input id="Celular" type="text" name="txtCelular"  value="<%=xCelular%>" required  />
			      </label></td>
			    </tr>
			    
			    <tr>
			      <td>Contrase&ntilde;a:</td>
			      <td><label>
						<input id="Clave" type="password" name="txtClave"  value="<%=xClave%>" required  />
			      </label></td>
			    </tr>

			    <tr>
			      <td>Tipo de Usuario:</td>
			      <td><label>
						<input type="text" list="TipoUsuario" name="txtTipoUsuario"   value="<%=xTipoUsuario%>" required /> 
						<datalist id="TipoUsuario">
							<option value="Docente"/>
							<option value="Alumno"/>
						</datalist>
			      </label></td>
			    </tr>

			    <tr>
			      <td colspan="2">
					<input type="hidden" id="IdUsuario" name="txtIdUsuario" value="<%=xIdUsuario%>"/>
					<input type="hidden" id="operacion" name="txtOperacion" value="<%=xOperacion%>"/>
					<input type="button" name="btnCancelar" value="Cancelar..." onclick="window.location='usuario_buscar.jsp'"/>
					<input type="submit" value="Enviar"/>
			      </td>
    			</tr>
    
			</table>
		</form>


		<!-- Site footer -->
		<div class="footer">
			 <p>&nbsp;</p>
		  <p>&copy; JNetworks 2014 </p>
		</div>

	 </div> <!-- /container -->
    
    <!-- Bootstrap core JavaScript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    
     <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="js/jquery-1.10.2.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap-3.1.1.js"></script>

</body>
</html>
